#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool is_geometric_sequence(const vector<ll> &a) {
  int n = a.size();
  if (n <= 2)
    return true;
  vector<ll> b = a;

  sort(b.begin(), b.end(), [](ll x, ll y) { return abs(x) < abs(y); });

  bool ok = true;
  for (int i = 0; i < n - 2; ++i) {
    if (b[i] * b[i + 2] != b[i + 1] * b[i + 1])
      ok = false;
  }
  if (ok)
    return true;

  // 考虑 r为-1 或者 1的情况
  //  所有数的绝对值都相同的情况：考虑正数和负数交叉排列，最后最多剩下一个整数或负数
  if (abs(b[0]) == abs(b.back())) {
    int pos = 0, neg = 0;
    for (auto k : b)
      if (k < 0)
        neg++;
      else
        pos++;
    if (abs(neg - pos) <= 1)
      return true;
  }

  return false;
}

int main() {
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
      cin >> A[i];
    }
    if (is_geometric_sequence(A)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}